import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

/* 先把VueRouter原型对象的push,先保存一份 */
let originPush = VueRouter.prototype.push;
let originReplace = VueRouter.prototype.replace;
//重写push|replace
/* 第一个参数：告诉原来的push方法，往哪里跳转 */

//重写push
VueRouter.prototype.push = function (location, resolve, reject) {
  if (resolve && reject) {
    //call||apply区别
    //相同点，都可以调用函数一次，都可以篡改函数的上下文一次
    //不同点：call与apply传递参数：call传递参数用逗号隔开，apply方法执行。传递数组
    //this还是用该上下文调用，也就是vuerouter的实例，后面跟参数指定跳的位置，以及成功失败的回调
    originPush.call(this, location, resolve, reject);
  } else {
    originPush.call(
      this,
      location,
      () => {},
      () => {}
    );
  }
};

//重写replace
VueRouter.prototype.replace = function (location, resolve, reject) {
  if (resolve && reject) {
    originReplace.call(this, location, resolve, reject);
  } else {
    originReplace.call(
      this,
      location,
      () => {},
      () => {}
    );
  }
};

const routes = [
  // {
  //   path: "/Login",
  //   redirect: "Login",
  // },

  {
    path: "/",
    name: "Index",
    component: () => import("../views/limits of authority/Index.vue"),
    // component: (resolve) =>
    //   require([""], resolve),
    meta: { title: "自述文件" },
    children: [
      {
        path: "/",
        name: "Dashboard",
        component: () => import("../views/404/Dashboard.vue"),
        meta: { title: "系统首页" },
      },
      {
        path: "/Menu",
        name: "Menu",
        component: () => import("../views/limits of authority/Menu.vue"),
        meta: { title: "菜单管理" },
      },
      {
        path: "/User",
        name: "User",
        component: () => import("../views/limits of authority/User.vue"),
        meta: { title: "用户管理" },
      },
      {
        path: "/Role",
        name: "Role",
        component: () => import("../views/limits of authority/Role.vue"),
        meta: { title: "角色管理" },
      },
      {
        path: "/aboutUs",
        name: "aboutUs",
        component: () => import("../views/aboutUs.vue"),
        meta: { title: "关于我们信息" },
      },
      {
        path: "/aboutUsImage",
        name: "aboutUsImage",
        component: () => import("../views/aboutUsImage.vue"),
        meta: { title: "关于我们图片" },
      },
      {
        path: "/Address",
        name: "Address",
        component: () => import("../views/Address.vue"),
        meta: { title: "收货地址" },
      },
      {
        path: "/Balance",
        name: "Balance",
        component: () => import("../views/Balance.vue"),
        meta: { title: "余额" },
      },
      {
        path: "/StationAddress",
        name: "StationAddress",
        component: () => import("../views/StationAddress.vue"),
        meta: { title: "门店创建信息" },
      },
      {
        path: "/StationEvaluate",
        name: "StationEvaluate",
        component: () => import("../views/StationEvaluate.vue"),
        meta: { title: "门店评价" },
      },
      {
        path: "/TbGoodsComment",
        name: "TbGoodsComment",
        component: () => import("../views/TbGoodsComment.vue"),
        meta: { title: "商品评论" },
      }, 
      {
        path: "/TutorialPicinfo",
        name: "TutorialPicinfo",
        component: () => import("../views/TutorialPicinfo.vue"),
        meta: { title: "洗车教程" },
      },
      {
        path: "/Station",
        name: "Station",
        component: () => import("../views/Station.vue"),
        meta: { title: "门店工位" },
      },
      {
        path: "/TbImage",
        name: "TbImage",
        component: () => import("../views/TbImage.vue"),
        meta: { title: "轮播图" },
      },
      {
        path: "/CarWashRecord",
        name: "CarWashRecord",
        component: () => import("../views/CarWashRecord.vue"),
        meta: { title: "洗车状态" },
      },
      {
        path: "/CheckoutInfo",
        name: "CheckoutInfo",
        component: () => import("../views/CheckoutInfo.vue"),
        meta: { title: "结算信息" },
      },
      {
        path: "/CreditInfo",
        name: "CreditInfo",
        component: () => import("../views/CreditInfo.vue"),
        meta: { title: "积分" },
      },
      {
        path: "/FeedbackInfo",
        name: "FeedbackInfo",
        component: () => import("../views/FeedbackInfo.vue"),
        meta: { title: "反馈信息" },
      },
      {
        path: "/tuser",
        name: "tuser",
        component: () => import("../views/tuser.vue"),
        meta: { title: "访客管理" },
      },
      {
        path: "/Integral",
        name: "Integral",
        component: () => import("../views/Integral.vue"),
        meta: { title: "信息管理" },
      },
      {
        path: "/Store",
        name: "Store",
        component: () => import("../views/Store.vue"),
        meta: { title: "门店信息" },
      },
      {
        path: "/Car",
        name: "Car",
        component: () => import("../views/Car.vue"),
        meta: { title: "车辆信息" },
      },
      {
        path: "/LoginLog",
        name: "LoginLog",
        component: () => import("../views/LoginLog.vue"),
        meta: { title: "登录日志统计" },
       },
       {
        path: "/SysOperLog",
        name: "SysOperLog",
        component: () => import("../views/SysOperLog.vue"),
        meta: { title: "操作日志记录信息" },
        },
        {
          path: "/RegionInfo",
          name: "RegionInfo",
          component: () => import("../views/RegionInfo.vue"),
          meta: { title: "地域信息" },
        },
        {
          path: "/CommodityType",
          name: "CommodityType",
          component: () => import("../views/CommodityType.vue"),
          meta: { title: "商品类型表" },
        },
        {
          path: "/Commodity",
          name: "Commodity",
          component: () => import("../views/Commodity.vue"),
          meta: { title: "商品类型表" },
        },
        {
          path: "/FeedbackPicInfo",
          name: "FeedbackPicInfo",
          component: () => import("../views/FeedbackPicInfo.vue"),
          meta: { title: "反馈信息图片表" },
        },
        {
          path: "/OrderStatusCode",
          name: "OrderStatusCode",
          component: () => import("../views/OrderStatusCode.vue"),
          meta: { title: "订单状态表" },
        },
        {
          path: "/TbOrderComment",
          name: "TbOrderComment",
          component: () => import("../views/TbOrderComment.vue"),
          meta: { title: "订单评价" },
        },
       
        {
          path: "/tborder",
          name: "tborder",
          component: () => import("../views/tborder.vue"),
          meta: { title: "订单" },
        }, 
        {
          path: "/TbProductImage",
          name: "TbProductImage",
          component: () => import("../views/TbProductImage.vue"),
          meta: { title: "商品图片" },
        }, 
    ],
  },
  {
    path: "/Login",
    name: "Login",
    component: () => import("../views/limits of authority/login/login.vue"),
  },
  {
    path: "/404",
    name: "404",
    component: () => import("../views/404/404.vue"),
    meta: { title: "404错误提示" },
  },
];

const router = new VueRouter({
  routes,
});

export default router;

//可以多次点击同一个路径，放置项目冗余

// 结束
